#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>

using namespace std;

#define MAXN 1005
#define MOD 1000000007
#define LL long long

int T, Cas = 1;

int N, M, a[MAXN], b[MAXN], bn;

LL cost[MAXN][MAXN], tmp[MAXN];

void hash_init() {
	sort(b + 1, b + 1 + N);
	bn = unique(b + 1, b + 1 + N) - b - 1;
	for (int i = 1; i <= N; i ++) {
		a[i] = lower_bound(b + 1, b + 1 + bn, a[i]) - b;
	}
}

int lowbit(int x) {
	return x & (-x);
}

void update(int pos, int x, LL add) {
	while (x <= bn) {
		cost[pos][x] += add;
		cost[pos][x] %= MOD;
		x += lowbit(x);
	}
}

LL query(int pos, int x) {
	LL res = 0LL;
	while (x) {
		res += cost[pos][x];
		res %= MOD;
		x -= lowbit(x);
	}
	return res;
}

void work() {
	memset(cost, 0, sizeof(cost));
	printf("Case #%d: ", Cas ++);
	scanf("%d %d", &N, &M);
	for (int i = 1; i <= N; i ++) {
		scanf("%d", &a[i]);
		b[i] = a[i];
	}
	hash_init();
	for (int i = 1; i <= N; i ++) {
		tmp[1] = 1;
		LL now = a[i];
		int big = min(i, M);
		for (int j = 1; j < big; j ++) {
			tmp[j + 1] = query(j, now - 1);
		}
		for (int j = 1; j <= i; j ++) {
			update(j, now, tmp[j]);
		}
	}
	LL ans = query(M, bn);
	printf("%I64d\n", ans);
}
int main()
{
	scanf("%d", &T);
	while (T --) {
		work();
	}
}

